/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  javafx.beans.value.ChangeListener
 *  javafx.beans.value.ObservableValue
 *  javafx.event.EventHandler
 *  javafx.fxml.FXML
 *  javafx.fxml.FXMLLoader
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Label
 *  javafx.scene.control.Slider
 *  javafx.scene.input.MouseEvent
 *  javafx.scene.layout.VBox
 */
package com.gys.common.plugIn.dateTimePicker;

import com.gys.common.plugIn.dateTimePicker.DateTimePickerPopup;
import com.gys.common.plugIn.dateTimePicker.HoursPicker;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;

public class MinuteSecondPicker
extends VBox
implements Initializable {
    private final DateTimePickerPopup parentContainer;
    @FXML
    private Slider slider;
    @FXML
    private Label label;

    MinuteSecondPicker(DateTimePickerPopup parentContainer) {
        this.parentContainer = parentContainer;
        URL url = HoursPicker.class.getClass().getResource("/fxml/dateTimePicker/MinuteSecondPicker.fxml");
        FXMLLoader fxmlLoader = new FXMLLoader();
        try {
            fxmlLoader = new FXMLLoader(url);
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
        fxmlLoader.setRoot(this);
        fxmlLoader.setController(this);
        try {
            fxmlLoader.load();
        }
        catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }

    public void initialize(URL location, ResourceBundle resources) {
        this.slider.setMin(0.0);
        this.slider.setMax(59.0);
        this.slider.valueProperty().addListener((ChangeListener)new ChangeListener<Number>(){

            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                int newValueInt = newValue.intValue();
                MinuteSecondPicker.this.label.setText(String.format("%02d", newValueInt));
            }
        });
        this.slider.onMouseReleasedProperty().set(new EventHandler<MouseEvent>(){

            public void handle(MouseEvent event) {
                MinuteSecondPicker.this.parentContainer.restoreTimePanel();
            }
        });
    }

    public int getValue() {
        return Integer.parseInt(this.label.getText());
    }
}

